<template>
	<view class="card-btns" @click.stop>
		<template v-for="i in $btns" v-if="!i.hide">
			<a-button :style="i.style" :key="i.name" v-if="!value.$status || !i.code || i.code.includes((value.$status || {}).code || '')" @click="i.click(value)">
				{{ i.name }}
			</a-button>
		</template>
	</view>
</template>

<script>
import { stringObject } from '@/y-ui/utils/api.js';
export default {
	props: {
		parameter: Object,
		value: Object,
		btns: {
			type: Array,
			default() {
				return [];
			}
		}
	},
	computed: {
		$btns() {
			return this.btns.map(x => {
				return {
					...x,
					name: typeof x.name === 'function' ? x.name(this.value) : x.name,
					hide: typeof x.hide === 'function' ? x.hide(this.value) : x.hide
				};
			});
		}
	}
};
</script>

<style scoped lang="scss">
.card-btns {
	padding: 0 15px;
	display: flex;
	justify-content: flex-end;
	flex-direction: row;
	flex-wrap: wrap;
	.y-button {
		margin:6px 2px;
		line-height: 1.9em;
		font-size: 14px;
		padding: 0 1.2em;
		vertical-align: middle;
	}
}
</style>
